![]() |
PATH![]() |
![]() ![]() |
The Repeat (number) Times form of the Repeat statement repeats a group of statements a specified number of times.
repeat integer [ times ]
[ statement ]...
end [ repeat ]
integer is an integer that specifies the number of times to repeat the statements in the body of the loop. The word times after integer is optional.
The following example numbers the paragraphs of a document with the Repeat (number) Times form of the Repeat statement.
tell document "Simple" of application "AppleWorks"
set numParagraphs to (count paragraphs of text body)
set paragraphNum to 1
repeat numParagraphs times
set paragraph paragraphNum of text body ¬
to (paragraphNum as string) ¬
& " " & paragraph paragraphNum of text body
set paragraphNum to paragraphNum + 1
end repeat
end tell